package com.config;


import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    /*
    1、交换机
    2、队列
    3、绑定他俩
     */
    @Bean("bootExchange1")
    public Exchange bootExchange(){
//        return new TopicExchange("bootExchange", true,false);
        return ExchangeBuilder.fanoutExchange("bootExchange1").durable(true).build();
//        return ExchangeBuilder.topicExchange(EXCHANGE_NAME).durable(true).build();
    }

    @Bean("bootQueue")
    public Queue bootQueue(){
        return new Queue("bootQueue");
    }

    @Bean
    public Binding bindingQueueExchange(@Qualifier("bootQueue") Queue queue,@Qualifier("bootExchange1") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("").noargs();
    }
}
